package com.example.photo.utils;

import java.security.SecureRandom;
import java.util.Random;

/**
 * 返回随机头像
 *
 * @author Lwh
 * @time 2023/04/12 19:58
 */
public class AvatarUtils {
    private static final String SYMBOLS = "123456789abcdef";
    private static final Random RANDOM = new SecureRandom();
    public static final String BASE_URL = "https://source.boringavatars.com/marble/120/Maria%20Mitchell?colors=";

    public static String getAvatarUrl() {
        char[] nonceChars = new char[6];
        for (int index = 0; index < nonceChars.length; ++index) {
            nonceChars[index] = SYMBOLS.charAt(RANDOM.nextInt(SYMBOLS.length()));
        }
        String rgb = new String(nonceChars);
        return BASE_URL + rgb;
    }
}
